package org.springframework.context;

import org.springframework.beans.BeansException;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * 自定义上下文实现类，添加环境变量验证
 *
 * @ClassName: MyClassPathXmlApplicationContext
 * @Author: songdongxu
 * @CreateDate: 2024/11/8 9:18
 * @Version: 1.0
 **/
public class MyClassPathXmlApplicationContext extends ClassPathXmlApplicationContext {

	public MyClassPathXmlApplicationContext(String... configLocations) throws BeansException {
		super(configLocations);
	}

	@Override
	protected void initPropertySources() {
		// 添加验证要求
		getEnvironment().setRequiredProperties("VAR");
	}
}
